﻿@page "{id:int?}"
@model Ninesky.Web.Pages.Admin.Category.AddModel

@{
    ViewData["Title"] = "添加栏目";
}
@section Nav
    {
    @Html.Partial("NavPartial")
}

<Breadcrumb>
    <Breadcrumb-Item><Icon type="ios-home-outline"></Icon> <a asp-page="/Admin/Home/Index"> 首页</a></Breadcrumb-Item>
    <Breadcrumb-Item><a asp-page="/Admin/Category/Index">栏目管理</a></Breadcrumb-Item>
    <Breadcrumb-Item>添加栏目</Breadcrumb-Item>
</Breadcrumb>
<card style="padding:8px 20px 8px 8px;">
    <content-view>
    </content-view>
</card>

<script type="text/template" id="category" v-pre>
    <div>
        <component v-bind:is="categoryEntity.type" v-on:typechange="typechange" v-bind:model="categoryEntity" v-bind:parent-categories="parentCategories">
        </component>
        <Spin size="large" fix v-if="spinData.visible">
            <Icon type="load-c" size=18 class="spin-icon-load"></Icon>
            <div>{{spinData.message}}</div>
        </Spin>
    </div>
</script>

<script type="text/template" id="general" v-pre>
    <Form ref="model" :model="model" :label-width="100" :rules="ruleValidate">
        <input type="hidden" v-model="model.categoryId" />
        <FormItem label="父栏目" prop="parentIds">
            <Cascader change-on-select :data="parentCategories" v-model="model.parentIds"></Cascader>
        </FormItem>

        <FormItem label="栏目类型" prop="type">
            <Select v-model='type'>
                <Option v-for="item in categoryType" :value="item.value" :key="item.value">{{ item.label }}</Option>
            </Select>
        </FormItem>
        <FormItem label="栏目名称" prop="name">
            <Input v-model='model.name' />
        </FormItem>
        <FormItem label="首页模板" prop="homeTemplate">
            <Input v-model="model.homeTemplate">
            <Button slot="append" icon="ios-search"></Button>
            </Input>
        </FormItem>
        <FormItem label="内容类型" prop="contentType">
            <Select v-model='model.contentType'>
                <Option v-for="item in contentType" :value="item.value" :key="item.value">{{ item.label }}</Option>
            </Select>
        </FormItem>
        <FormItem label="列表页模板" prop="listTemplate" v-if="model.contentType!='NotSet'">
            <Input v-model="model.listTemplate">
            <Button slot="append" icon="ios-search"></Button>
            </Input>
        </FormItem>
        <FormItem label="内容页模板" prop="contentTemplate" v-if="model.contentType!='NotSet'">
            <Input v-model="model.contentTemplate">
            <Button slot="append" icon="ios-search"></Button>
            </Input>
        </FormItem>
        <FormItem label="Meta关键字" prop="meta_Keywords">
            <Input v-model="model.meta_Keywords" type="textarea"></Input>
        </FormItem>
        <FormItem label="Meta描述" prop="meta_Description">
            <Input v-model="model.meta_Description" type="textarea"></Input>
        </FormItem>
        <FormItem label="说明" prop="description">
            <Input v-model="model.description" type="textarea"></Input>
        </FormItem>
        <FormItem label="排序" prop="order">
            <InputNumber :min="0" v-model="model.order"></InputNumber>
        </FormItem>
        <FormItem>
            <Button type="primary" icon="checkmark" v-on:click="handleSubmit('model')">保存</Button>
        </FormItem>
        <Spin size="large" fix v-if="spinData.visible">
            <Icon type="load-c" size=18 class="spin-icon-load"></Icon>
            <div>{{spinData.message}}</div>
        </Spin>
    </Form>
</script>

<script type="text/template" id="page" v-pre>
    <Form ref="model" :model="model" :label-width="100" :rules="ruleValidate">
        <input type="hidden" v-model="model.categoryId" />
        <FormItem label="父栏目" prop="parentIds">
            <Cascader change-on-select :data="parentCategories" v-model="model.parentIds"></Cascader>
        </FormItem>
        <FormItem label="栏目类型" prop="type">
            <Select v-model='type'>
                <Option v-for="item in categoryType" :value="item.value" :key="item.value">{{ item.label }}</Option>
            </Select>
        </FormItem>
        <FormItem label="栏目名称" prop="name">
            <Input v-model='model.name' />
        </FormItem>
        <FormItem label="首页模板" prop="homeTemplate">
            <Input v-model="model.homeTemplate">
            <Button slot="append" icon="ios-search"></Button>
            </Input>
        </FormItem>
        <FormItem label="Meta关键字" prop="meta_Keywords">
            <Input v-model="model.meta_Keywords" type="textarea"></Input>
        </FormItem>
        <FormItem label="Meta描述" prop="meta_Description">
            <Input v-model="model.meta_Description" type="textarea"></Input>
        </FormItem>
        <FormItem label="说明" property="description">
            <Input v-model="model.description" type="textarea"></Input>
        </FormItem>
        <FormItem label="排序" prop="order">
            <InputNumber :min="0" v-model="model.order"></InputNumber>
        </FormItem>
        <FormItem>
            <Button type="primary" icon="checkmark" v-on:click="handleSubmit('model')">保存</Button>
        </FormItem>
    </Form>
</script>

<script type="text/template" id="link" v-pre>
    <Form ref="model" :model="model" :rules="ruleValidate" :label-width="100">
        <input type="hidden" v-model="model.categoryId" />
        <FormItem label="父栏目" prop="parentIds">
            <Cascader change-on-select :data="parentCategories" v-model="model.parentIds"></Cascader>
        </FormItem>

        <FormItem label="栏目类型" prop="type">
            <Select v-model='type'>
                <Option v-for="item in categoryType" :value="item.value" :key="item.value">{{ item.label }}</Option>
            </Select>
        </FormItem>
        <FormItem label="栏目名称" prop="name">
            <Input v-model='model.name' />
        </FormItem>
        <FormItem label="链接地址" prop="linkUrl">
            <Input v-model="model.linkUrl"></Input>
        </FormItem>
        <FormItem label="说明" prop="description">
            <Input v-model="model.description" type="textarea"></Input>
        </FormItem>
        <FormItem label="排序" prop="order">
            <InputNumber :min="0" v-model="model.order"></InputNumber>
        </FormItem>
        <FormItem>
            <Button type="primary" icon="checkmark" v-on:click="handleSubmit('model')">保存</Button>
        </FormItem>
        <Spin size="large" fix v-if="spinData.visible">
            <Icon type="load-c" size=18 class="spin-icon-load"></Icon>
            <div>{{spinData.message}}</div>
        </Spin>
    </Form>
</script>


@section Scripts {
    <script>
        const parentId = '@Model.parentId';
    </script>
    <script src="~/admin/js/models/category.js"></script>
    <script src="~/admin/js/models/spinData.js"></script>
    <script src="~/admin/js/models/categoryTypeList.js"></script>
    <script src="~/admin/js/models/ContnetTypeList.js"></script>
    <script src="~/admin/js/category/add.js"></script>
}

